import java.util.Stack;
public class Solution {
    public boolean IsPopOrder(int[] pushA,int[] popA){
        //入栈过程中可以出栈
        if (pushA.length == 0 || popA.length == 0){
            return false;
        }
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushA.length; i++){
            stack.push(pushA[i]);
            while (j < popA.length && !stack.empty() && stack.empty() && stack.peek().equals(popA[j])) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
}
